package com.project.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.entity.po.Admin;

/**
 * @ProjectName: 
 * @Package: 
 * @ClassName: 
 * @Author: ZhaoLongShi
 * @CreateDate: 
 */
public interface AdminMapper extends BaseMapper<Admin> {
    /**
     * 检查用户名是否存在
     * @param username
     * @return
     */
   default Admin selectAdminByName(String username){
       QueryWrapper<Admin> qw = new QueryWrapper<>();
       qw.lambda().eq(Admin::getUsername,username);
       return this.selectOne(qw);
   }

    /**
     *  校验密码
     * @param username
     * @param password
     * @return
     */
   default Admin checkPassword(String username,String password){
       QueryWrapper<Admin> qw = new QueryWrapper<>();
       qw.lambda().eq(Admin::getUsername,username).and(a->{
           qw.lambda().eq(Admin::getPassword,password);
       });
       return this.selectOne(qw);
   }
}